/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.system.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;

/**
* @website https://el-admin.vip
* @description /
* @author wangyu
* @date 2024-03-20
**/
@Entity
@Data
@Table(name="user_account")
public class UserAccount implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "acct_id")
    @TableId(value = "acct_id", type = IdType.AUTO)
    @ApiModelProperty(value = "主键ID")
    private Long acctId;

    @Column(name = "acct_code",unique = true)
    @ApiModelProperty(value = "账户编码")
    private String acctCode;

    @Column(name = "total_amount")
    @ApiModelProperty(value = "账户总金额")
    private BigDecimal totalAmount;

    @Column(name = "usable_amount")
    @ApiModelProperty(value = "可用总金额")
    private BigDecimal usableAmount;

    @Column(name = "frozen_amount")
    @ApiModelProperty(value = "冻结总金额")
    private BigDecimal frozenAmount;

    @Column(name = "open_id")
    @ApiModelProperty(value = "openid")
    private String openId;

    @Column(name = "sys_user_id")
    @ApiModelProperty(value = "系统用户id")
    private Long sysUserId;

    @Column(name = "use_ratio")
    @ApiModelProperty(value = "金额使用比例")
    private BigDecimal useRatio;

    @Column(name = "acct_type")
    @ApiModelProperty(value = "账户类型")
    private Integer acctType;

    @Column(name = "status")
    @ApiModelProperty(value = "状态")
    private Integer status;

    @Column(name = "start_time")
    @ApiModelProperty(value = "可使用开始时间")
    private Timestamp startTime;

    @Column(name = "end_time")
    @ApiModelProperty(value = "可使用结束时间")
    private Timestamp endTime;

    @Column(name = "expire_time")
    @ApiModelProperty(value = "过期时间")
    private Timestamp expireTime;

    @Column(name = "create_time")
    @ApiModelProperty(value = "创建时间")
    private Timestamp createTime;

    @Column(name = "update_time")
    @ApiModelProperty(value = "更新时间")
    private Timestamp updateTime;

    @Column(name = "mobile")
    @ApiModelProperty(value = "手机号")
    private String mobile;

    public void copy(UserAccount source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}